﻿package frEngine.shader.md5shader
{
    import baseEngine.core.*;
    import flash.display3D.*;
    import flash.events.*;
    import frEngine.core.*;
    import frEngine.shader.filters.fragmentFilters.*;
    import frEngine.shader.filters.fragmentFilters.extra.*;
    import frEngine.shader.filters.vertexFilters.*;
    import frEngine.shader.registType.*;

    public class OutLightingShader extends Md5ShaderBase
    {
        private var _edgeTextureRg:FsParam;
        private var _outLightColorReg:FcParam;
        private var _outSizeReg:VcParam;

        public function OutLightingShader(param1:int, param2:VertexFilter, param3:FragmentFilter)
        {
            super(param1, param2, param3);
            this.initOutLightingMaterialParams(param1);
            return;
        }// end function

        private function initOutLightingMaterialParams(param1:int) : void
        {
            this.materialParams.addFilte(new VertexNormalFilter());
            this.materialParams.addFilte(new InflateFilter());
            this.materialParams.cullFace = Context3DTriangleFace.NONE;
            this.materialParams.depthWrite = false;
            this.materialParams.setBlendMode(EBlendType.BLEND_ALPHA0);
            return;
        }// end function

        override protected function materialRebuilder(event:Event) : void
        {
            super.materialRebuilder(event);
            this._outLightColorReg = getParam("{outColor}", false);
            this._edgeTextureRg = getParam("{texture1}", false);
            this._outSizeReg = getParam("{OutSize}", true);
            return;
        }// end function

        public function changeParams(param1:Number, param2:Number, param3:Number, param4:Number, param5:Texture3D, param6:Number) : void
        {
            var _loc_7:Texture3D = null;
            if (this._outLightColorReg)
            {
                this._outLightColorReg.changeValue4(param1, param2, param3, param4);
            }
            if (this._edgeTextureRg && this._edgeTextureRg.value != param5)
            {
                _loc_7 = this._edgeTextureRg.value;
                if (_loc_7 && _loc_7.format != param5.format)
                {
                    TextureFilter(this.materialParams.fragmentFilter).texture = param5;
                    this.materialParams.needRebuild = true;
                }
                this._edgeTextureRg.value = param5;
            }
            if (this._outSizeReg)
            {
                this._outSizeReg.changeValue1(2, param6);
            }
            return;
        }// end function

    }
}
